const crypto = require('crypto');
const path = require('path');



function genRandomName(filename, length=16) {
  const randomBytes = crypto.randomBytes(16); // 生成一个随机的字节数组
  const randomHex = randomBytes.toString('hex'); // 将字节数组转换为十六进制字符串
  const randomName = randomHex.slice(0, length); // 调整长度
  return `${randomName}${path.extname(filename)}`;
}


module.exports = genRandomName;